import { store_name } from './util'

chrome.runtime.onMessageExternal.addListener(function (request) {
  if (request.token) {
    chrome.storage.local.set({ [store_name]: request.token })
  }

  if (request.isLoginOut) {
    chrome.storage.local.remove(store_name)
  }

  if (request.tabs) {
    request.tabs.forEach(item => {
      chrome.tabs.create({
        url: item.url,
      })
    })
  }
})

export {}
